﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace HML.SkinTool
{
    public partial class 新建主题Form : Form
    {
        public 新建主题Form()
        {
            InitializeComponent();
        }

        private void 新建主题Form_Load(object sender, EventArgs e)
        {
            Dictionary<string, XmlDocument> skins = (Dictionary<string, XmlDocument>)typeof(SkinManager).GetProperty("AllSkins", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null, null);
            foreach (KeyValuePair<string, XmlDocument> item in skins)
            {
                this.skinsComboBox.Items.Add(item.Key);
                this.skinsComboBox.SelectedItem = Skins.Dark.ToString();
            }
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            if (this.skinsComboBox.SelectedItem == null)
            {
                MessageBox.Show("请选择要参考的主题","操作取消");
                return;
            }
            string name = this.skinNameTextBox.Text.Trim();
            if (name=="")
            {
                MessageBox.Show("请输入主题名称", "操作取消");
                return;
            }
            Dictionary<string, XmlDocument> skins = (Dictionary<string, XmlDocument>)typeof(SkinManager).GetProperty("AllSkins", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null, null);
            if (skins.ContainsKey(name))
            {
                MessageBox.Show("主题名称已存在", "操作取消");
                return;
            }
            this.DialogResult = DialogResult.OK;
        }
    
        private void cancelButton_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

    }
}
